package gov.nist.ssd.swqb.commands;

import gov.nist.ssd.swqb.core.Display;
import gov.nist.ssd.swqb.core.exceptions.OutOfBoundsException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Benjamin Herbomez
 */
public class NextPage implements Command{

    private Display display;

    public NextPage(Display d) {
        this.display = d;
    }
    
    @Override
    public void exec() {
        int i = display.getCurrentPageIndex();
        if(i < display.getPageCount()-1)
            try {
            display.setPageIndex(i+1);
        } catch (OutOfBoundsException ex) {
            Logger.getLogger(NextPage.class.getName()).log(Level.WARNING, null, ex);
        }
    }

    @Override
    public void unExec() {
        
        int i = display.getCurrentPageIndex();
            try {
            display.setPageIndex(i-1);
        } catch (OutOfBoundsException ex) {
            Logger.getLogger(NextPage.class.getName()).log(Level.WARNING, null, ex);
        }
    }
    
}
